package com.example.adminui.controller;

import com.example.adminui.entity.LeadDistribution;
import com.example.adminui.service.LeadDistributionService;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/lead-distributions")
public class LeadDistributionController {
    private final LeadDistributionService leadDistributionService;

    public LeadDistributionController(LeadDistributionService leadDistributionService) {
        this.leadDistributionService = leadDistributionService;
    }

    @PostMapping
    public void create(@RequestBody LeadDistribution leadDistribution) {
        leadDistributionService.save(leadDistribution);
    }

    @PutMapping("/{id}")
    public void update(@PathVariable Long id, @RequestBody LeadDistribution leadDistribution) {
        leadDistribution.setId(id);
        leadDistributionService.updateById(leadDistribution);
    }

    @DeleteMapping("/{id}")
    public void delete(@PathVariable Long id) {
        leadDistributionService.removeById(id);
    }

    @GetMapping("/{id}")
    public LeadDistribution get(@PathVariable Long id) {
        return leadDistributionService.getById(id);
    }
}